<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let url = 'http://www.shidazhi.cn/index.html?1x=1&name=zhufeng&teacher=aaa#box'
        let obj = {}
        let askIndex = url.indexOf('?')//获得?索引
        let wellIndex = url.indexOf('#')//获得#号索引
        let askText = url.substring(askIndex + 1, wellIndex)//1x=1&name=zhufeng&teacher=aaa
        let wellText = url.substring(wellIndex + 1)
        let askAry = askText.split('&')
        askAry.forEach((item, index) => {
            let n = item.split('=')
            let j = n[0]
            let k = n[1]
            obj[j] = k
        })
        obj.HASH = wellText
        console.log(obj);
    </script>
</body>

</html>